<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
  <f:metadata>   		
   	</f:metadata>
   
   	<ui:define name="content">
   
		<h:form id="editForm">         
			<p:panel id="panel" header="Form" style="margin-bottom:10px;">
		       <p:messages id="messages" closable="true"><p:autoUpdate/></p:messages>
		        
		        <h:panelGrid columns="2" cellpadding="5">
		       		 <h:outputText for="path" value="文件名称" />
					<h:inputText id="path" value="#{fileDownloadView2.fileName}" />
				</h:panelGrid>
			</p:panel>
			
			<p:commandButton style="margin-left:10px;" value="下载" ajax="false"  icon="ui-icon-arrowthick-1-s">
									        <p:fileDownload value="#{fileDownloadView2.download()}" />
			</p:commandButton>
			
			<p:commandButton rendered="false" style="margin-left:10px;" value="下载app" ajax="false"  icon="ui-icon-arrowthick-1-s">
									        <p:fileDownload value="#{fileDownloadView2.downloadApp('hhsjzzjjy.apk')}" />
			</p:commandButton>
			
			<p:panel
					id="attachmentsPanel"
					header="相关附件"
					style="margin-bottom:10px;"
					styleClass="nureg-cont nuregcbox nuregcboxsty"
				>
					<p:fileUpload
						id="attachmentUploadFile"
						label="选择"
						mode="advanced"
						required="true"
						multiple="true"
						skinSimple="true"
						sizeLimit="#{1024 * 1024 * 3}"
						uploadLabel="上传"
						cancelLabel="取消"
						fileUploadListener="#{fileDownloadView2.uploadAttachment}"
					/>
						
			 </p:panel>
			 
			 <p:panel
					
					header="上传app(中介名称必须为hhsjz.apk(审核组为hhsjz_shz.apk))或资源包"
					style="margin-bottom:10px;"
					styleClass="nureg-cont nuregcbox nuregcboxsty"
				>
					<p:fileUpload
						id="appUploadFile"
						label="选择"
						mode="advanced"
						required="true"
						multiple="true"
						skinSimple="true"
						sizeLimit="#{1024 * 1024 * 20}"
						uploadLabel="上传"
						cancelLabel="取消"
						fileUploadListener="#{fileDownloadView2.uploadAppGwt}"
					/>
						
			 </p:panel>
			 
			 输入中介app版本号：<p:inputText class="versionNum" /> <p:button id="updateVersion" onclick="updateVersion()" value="更新中介版本号"></p:button>
			  输入中介审核组版本号：<p:inputText class="versionNum_profession" /> <p:button id="updateProfessionVersion" onclick="updateProfessionVersion()" value="更新审核组版本号"></p:button>
			 <script >
			 	function updateVersion(){
				 		var versionNum = $(".versionNum").val();
				 		if(versionNum == ''){
							alert("请填写版本号");
							return false;
					 	}
					 	
			 		 	var url = "${request.getContextPath()}/rest/download/updateAppVersion/"+versionNum;
						$.ajax({
						url:url,
						type:'post',
						async:false,
						success:function(data){
							if(data.status == 200 ){
								alert("更新成功！");
							}else{
								alert("更新失败！");
								}
						},
						error:function(e){
							console.log(e);
						}
					});

				 }
				
			 	function updateProfessionVersion(){
			 		var versionNum = $(".versionNum_profession").val();
			 		if(versionNum == ''){
						alert("请填写版本号");
						return false;
				 	}
				 	
		 		 	var url = "${request.getContextPath()}/rest/download/updateProfessionAppVersion/"+versionNum;
		 		 	debugger;
					$.ajax({
					url:url,
					type:'post',
					async:false,
					success:function(data){
						if(data.status == 200 ){
							alert("更新成功！");
						}else{
							alert("更新失败！");
							}
					},
					error:function(e){
						console.log(e);
					}
				});

			 }
			 </script>
		</h:form>
      
   	</ui:define>
</ui:composition>
 